import requests
from flask import current_app


def send_feedback_to_wexin(one_feedback):
    send_url = "https://sc.ftqq.com/SCU70393T033349da64e2de3e985f582c3297d5615dfdd8f1f10f5.send?text=%s&desp=%s" % (
        "惠惠购反馈", one_feedback
    )
    try:
        requests.get(send_url)
        current_app.logger.warning("成功发送反馈信息。")
    except Exception as e:
        current_app.logger.warning("发送server酱错误：")
        current_app.logger.warning(e)


def send_searchword_to_wexin(ip, search_word):
    send_url = "https://sc.ftqq.com/SCU70393T033349da64e2de3e985f582c3297d5615dfdd8f1f10f5.send?text=%s&desp=%s" % (
        ip, search_word
    )
    try:
        requests.get(send_url)
        current_app.logger.warning("成功发送搜索信息。")
    except Exception as e:
        current_app.logger.warning("发送server酱错误：")
        current_app.logger.warning(e)


def send_msg_to_weixin(title, text):
    send_url = "https://sc.ftqq.com/SCU70393T033349da64e2de3e985f582c3297d5615dfdd8f1f10f5.send?text=%s&desp=%s" % (
        title, text
    )
    try:
        requests.get(send_url)
        current_app.logger.warning("成功发送搜索信息。")
    except Exception as e:
        current_app.logger.warning("发送server酱错误：")
        current_app.logger.warning(e)
